home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 718 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.9 KB

  1. From: bill@amber.ssd.hcsc.com (Bill Leonard)
  2. Message-ID: <4i9cn4$7cf@ns.hcsc.com>
  3. X-Original-Date: 14 Mar 1996 15:07:16 GMT
  4. Path: in2.uu.net!bounce-back
  5. Date: 14 Mar 96 16:29:27 GMT
  6. Approved: fjh@cs.mu.oz.au
  7. Newsgroups: comp.std.c++
  8. Subject: Re: String value of enum
  9. Organization: Harris Computer Systems, Ft. Lauderdale FL
  10. References: <4i5sf3$89c@hermes.is.co.za> <Do81tp.H9u@rsvl.unisys.com> <4i8a38$2qq@engnews1.Eng.Sun.COM>
  11. Reply-To: Bill.Leonard@mail.hcsc.com
  12. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  13.     iQBFAgUBMUhJe+EDnX0m9pzZAQHe2AF/YM+v92fxiWmQnaoGOXpdRcIT0mxXHxu4
  14.     CcrblhPc1Ay4d2ykIv2Eh3SsA52SLkx6
  15.     =joSR
  16.  
  17. In article <4i8a38$2qq@engnews1.Eng.Sun.COM>, clamage@Eng.Sun.COM
  18. (Steve Clamage) writes:
  19. > It would not in fact be difficult to do, since only a table of
  20. > strings per enum type would be needed. The information is normally
  21. > put into debug info if you compile in debug mode anyway so the
  22. > debugger can display the labels instead of the values. A language
  23. > mechanism to make that data always available is probably too
  24. > expensive a price for every program to pay in order to support
  25. > this requirement which isn't very common and which can be solved
  26. > easily in source code.
  27.  
  28. Well, it is not that hard for the compiler to put out the tables only if
  29. you use the feature, so there is no need for every program to pay a penalty
  30. for this feature.
  31.  
  32. As for "solved easily in source code", it's not nearly as easy as just
  33. saying something like "enumvar.String()". :-)
  34.  
  35. > The more general case of non-contiguous enum values could be handled
  36. > by a table of value/string pairs and a lookup function. The standard
  37. > "map" class will do it all for you.
  38.  
  39. But using the map class would require initialization at runtime, wouldn't
  40. it?  That increases the startup cost of the program.  Using a sorted array
  41. of value/string pairs (statically initialized) and a binary search would
  42. probably be more efficient.
  43.  
  44. -- 
  45. Bill Leonard
  46. Harris Computer Systems Corporation
  47. 2101 W. Cypress Creek Road
  48. Fort Lauderdale, FL  33309
  49. Bill.Leonard@mail.hcsc.com
  50.  
  51. These opinions and statements are my own and do not necessarily reflect the
  52. opinions or positions of Harris Computer Systems Corporation.
  53.  
  54. ------------------------------------------------------------------------------
  55. There's something wrong with an industry in which amazement is a common
  56. reaction to things going right.
  57.  
  58. "Hard work never scared me.  Oh, sure, it has startled me from a distance."
  59.                                                        -- Professor Fishhawk
  60. ------------------------------------------------------------------------------
  61. ---
  62. [ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
  63. [ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
  64. [ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
  65. [ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
  66. [ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]
  67.